<template>
  <div class="searchMain" style="display: inline-block;">
    <div
      v-if="type === 'WB'"
      class="inlineForm"
    >
      <el-input v-model="sVal" class="clearItem" placeholder="" clearable />
    </div>
    <div
      v-if="type === 'JE'"
      class="inlineForm"
    >
      <el-input v-model="sVal" oninput="value=value.replace(/[^\d.]/g,'')" class="clearItem" :placeholder="$t('金额')" clearable />
    </div>
    <div
      v-if="type === 'ZD'"
      class="inlineForm"
    >
      <el-select v-model="sVal" class="clearItem" clearable :placeholder="$t('请选择')">
        <el-option
          v-for="dict in chooseList"
          :key="dict.dictValue"
          :label="$t(dict.dictLabel)"
          :value="dict.dictValue"
        />
      </el-select>
    </div>
    <div
      v-if="type === 'RQ'"
      class="inlineForm"
    >
      <el-input
        v-if="condition === 'SJN'"
        v-model="sVal"
        type="number"
        clearable
        min="0"
      />
      <DatePicker
        v-else
        v-model="sVal"
        class="clearItem"
        type="date"
        :placeholder="$t('日期')"
      />
    </div>
    <div
      v-if="type === 'YH'"
      class="inlineUser"
    >
      <userSelect
        v-model="sVal"
        class="clearItem"
        :placeholder="$t('用户')"
      />

    </div>
    <div
      v-if="type === 'BM'"
      class="inlineUser"
    >
      <DeptSelect
        v-model="sVal"
        class="clearItem"
        :placeholder="$t('部门')"
      />

    </div>
  </div>
</template>
<script>
export default {
  name: 'SearchMain',
  props: {
    type: {
      type: String,
      default: () => ''
    },
    chooseList: {
      type: Array,
      default: () => []
    },
    value: {
      type: [String, Number, Date, Object],
      default: ''
    },
    condition: {
      type: String,
      default: () => ''
    }
  },
  data() {
    return {
      sVal: this.value
    }
  },
  watch: {
    sVal(val) {
      this.$emit('input', val)
    },
    value(val) {
      this.sVal = val
    }
  }

}
</script>
